//
//  UIView+Lc.h
//  18Birdies
//
//  Created by Lc on 15/3/31.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import <UIKit/UIKit.h>

static UIRectCorner UIRectCornerTop = UIRectCornerTopLeft | UIRectCornerTopRight;
static UIRectCorner UIRectCornerBottom = UIRectCornerBottomLeft | UIRectCornerBottomRight;
static UIRectCorner UIRectCornerLeft = UIRectCornerTopLeft | UIRectCornerBottomLeft;
static UIRectCorner UIRectCornerRight = UIRectCornerTopRight | UIRectCornerBottomRight;

@interface UIView (Lc)

- (void)enableBackgroundColorIfDebug;

/**
 *  Following properties and methods SHOULD NOT be used while using AutoLayout.
 */

@property(nonatomic, assign) CGFloat width;
@property(nonatomic, assign) CGFloat height;
@property(nonatomic, assign) CGFloat posX;
@property(nonatomic, assign) CGFloat posY;
@property(nonatomic, assign) CGPoint centerPos;
@property(nonatomic, assign) CGFloat top;
@property(nonatomic, assign) CGFloat bottom;
@property(nonatomic, assign) CGFloat left;
@property(nonatomic, assign) CGFloat right;
@property(nonatomic, assign) CGSize size;
@property(nonatomic, assign) CGFloat centerX;
@property(nonatomic, assign) CGFloat centerY;

- (CGPoint)brPos;
- (CGPoint)centerPos;

- (void)setTop:(CGFloat)top;
- (void)setBottom:(CGFloat)bottom;
- (void)setWidth:(CGFloat)width;
- (void)setHeight:(CGFloat)height;
- (void)setPosX:(CGFloat)posx;
- (void)setPosY:(CGFloat)posy;
- (void)setLeft:(CGFloat)left;
- (void)setRight:(CGFloat)right;
- (void)centerToView:(UIView*)view;
- (void)centerToRect:(CGRect)rect;
- (void)setSize:(CGSize)size;

- (void)moveUp:(CGFloat)len;
- (void)moveRight:(CGFloat)len;

- (void)showLoadingIndicator;
- (void)removeLoadingIndicator;

- (void)removeAllSubviews;
- (void)hideAllSubviews;

- (void)removeAllGestures;

- (UIView*)findFirstResponder;

+ (void)hideKeyBoard;
- (void)hideKeyBoard;

- (UIImage*)snapShot;

- (void)setEqualWidthHeightLayoutWithSuperView:(UIView*)superView;
- (void)setEdgeInsets:(UIEdgeInsets)edgeInsets superView:(UIView*)superView;

/**
 水平线性渐变

 @param frame frame description
 @param colors CGColor array, e.g. @[(id)[UIColor redColor].CGColor, (id)[UIColor whiteColor].CGColor]
 */
- (void)addHorizontalLinearLayer:(CGRect)frame colors:(NSArray*)colors;
/**
 垂直线性渐变

 @param frame frame description
 @param colors CGColor array, e.g. @[(id)[UIColor redColor].CGColor, (id)[UIColor whiteColor].CGColor]
 */
- (void)addVerticalLinearLayer:(CGRect)frame colors:(NSArray*)colors;
// 默认渐变
- (void)addLinearLayer:(CGRect)frame colors:(NSArray*)colors;

- (void)clearLinearLayer;

@end

@interface UIView (UIViewController)

- (UIViewController*)parentViewController;

@end

@interface UIView (UIRectCorner)

/**
 * Need Reupdate When View's size change
 */
- (void)setCorner:(UIRectCorner)cornerType cornerRaius:(CGFloat)cornerRadius;
- (void)clearCorner;

@end
